{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle\n",
    "from time import time\n",
    "cookies = pickle.load(open(\"cookie.pkl\", \"rb\"))\n",
    "for e in cookies:\n",
    "    if 'expiry' in e:\n",
    "        print(int((e['expiry'] - time())/3600))\n",
    "        e.pop('expiry')\n",
    "print(e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import time\n",
    "print(str(time.time()) + \".png\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import difflib\n",
    "str1 = \"我是一个兵\"\n",
    "str2 = \"我是一个兵 \"\n",
    "ret = difflib.SequenceMatcher(None, str1, str2)\n",
    "ratio = ret.ratio()\n",
    "print(ratio)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re\n",
    "pattern = re.compile(r'<([a-zA-Z]+)>(.*)</\\1>')#两个圆括号中的内容表示分组([a-zA-Z]+)、(.*)\n",
    "s = '<html>hello world</html>'\n",
    "ret = re.search(pattern, s)\n",
    "\n",
    "print('re.groups():', ret.groups())#以元组的形式返回所有匹配的分组元素\n",
    "print('re.group():', ret.group())#不考虑分组，返回整个匹配到的字符\n",
    "print('re.group(0):', ret.group(0))#不考虑分组，返回整个匹配到的字符\n",
    "print('re.group(1):', ret.group(1))#返回分组中第1个元素，计数从1开始\n",
    "print('re.group(2):', ret.group(2))#返回分组中第2个元素，计数从2开始"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from datetime import datetime as dt\n",
    "print(str(dt.now()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n"
     ]
    }
   ],
   "source": [
    "import regex as re\n",
    "print(re.search(r'(?<=\\/)(\\d{1,2})', r'1/5').group())"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "ac59ebe37160ed0dfa835113d9b8498d9f09ceb179beaac4002f036b9467c963"
  },
  "kernelspec": {
   "display_name": "Python 3.9.5 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
